import React, { Component } from 'react'
// import qs from 'querystring'

const DetailData = [
    { id: '001', content: '我爱你，中国' },
    { id: '002', content: '我爱你，世界' },
    { id: '003', content: '我爱你，宇宙' }
]
export default class Detail extends Component {
    render() {
        // 接收params参数
        // const { id, title } = this.props.match.params

        // 接收search参数
        // const { search } = this.props.location
        // const { id, title } = qs.parse(search.slice(1))

        // 接收state参数
        const { id, title } = this.props.location.state || {}

        const detailResult = DetailData.find((detailObj) => {
            return detailObj.id === id
        }) || {}
        return (
            <ul>
                <li>ID:{id}</li>
                <li>TITLE:{title}</li>
                <li>CONTENT:{detailResult.content}</li>
            </ul>
        )
    }
}
